<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function Person(name) {
            this.name = name
            console.log(this)
        }
        Person.prototype.getName = function () {
            console.log(this.name)
        }
        function Car(model) {
            this.model = model
        }
        Car.prototype.getModel = function () {
            console.log(this.model)
        }
        function create(type, param) {
            return new this[type](param)
        }
        create.prototype = {
            person: Person,
            car: Car
        }
        var person1 = new create('person', 'iverson')
        person1.getName()

        /*
            new create('person', 'iverson') => {
                __proto__: create.prototype
            }

            new this[type](param) => new Person('iverson')
                __proto__: Person.prototype
                name: 'iverson'
        */
       
    </script>
</head>

<body>

</body>

</html>